﻿import com.dmotiko.mirador.*
import com.dmotiko.general.*
import mx.utils.Delegate;
import mx.video.*;

class MiradorRoomVideo
extends BaseClip {
		
	private var btnNuestrosSalones:Button;
	private var btnGaleria:Button;
	private var btnCapacidad:Button;
	private var mcPlay:MovieClip;
	private var mcPause:MovieClip;
	private var mcStop:MovieClip;
	private var flvPlayer:FLVPlayback;
	
	private var mcHeader:MovieClip;
	private var seekBar:MovieClip;
		
	private function initClip():Void {
		super.initClip();
			
		var root:MiradorRoomVideo = this;
		btnGaleria.onRelease = function() {
			root.dispatchEvent( { target: root, type: BaseClipEvent.CHANGED, section: MiradorNuestrosSalones.GALERIA_FRAME } )
		}
		btnCapacidad.onRelease = function() {
			root.dispatchEvent( { target: root, type: BaseClipEvent.CHANGED, section: MiradorNuestrosSalones.CAPACIDAD_FRAME } )
		}
		btnNuestrosSalones.onRelease = function() {
			root.dispatchEvent( { target: root, type: BaseClipEvent.CHANGED, section: MiradorNuestrosSalones.HOME_FRAME } )
		}
		
		var timer:MovieClip = this.createEmptyMovieClip( "timer", this.getNextHighestDepth());
		timer.onEnterFrame = function() {
			delete this.onEnterFrame;
			Delegate.create(root, root.initVideo)();
		}
	}
	
	private function refreshData():Void {
		switch( data.name ) {
			case "danbro":
			mcHeader.gotoAndStop(1);
			break;
			
			case "mirador":
			mcHeader.gotoAndStop(2);
			break;
			
			case "altos":
			mcHeader.gotoAndStop(3);
			break;
		}
	}
	
	private function initVideo():Void {
		flvPlayer.playButton = mcPlay;
		flvPlayer.pauseButton = mcPause;
		flvPlayer.stopButton = mcStop;
		flvPlayer.seekBar = seekBar;
		flvPlayer.load( getData().video );
		flvPlayer.play();
		MiradorSite.getApp().getMiradorSound().pauseMusic(true, flvPlayer);
	}
	
}